package com.lm.scau.dyb.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.lm.scau.dyb.activity.base.BaseActivity;

/**
 * Function:
 * auth：liming on 2016/8/12 15:33
 * mail：liming@wxchina.com
 */
public class SharepreferenceUtil {
    private static SharedPreferences sp;
    private static SharepreferenceUtil util;

    public static SharepreferenceUtil getInstance(BaseActivity activity) {
        if (null == util) {
            util = new SharepreferenceUtil();
            sp = activity.getSharedPreferences(FlagHelper.SHAREPREFERENCE_KEY, Context.MODE_PRIVATE);
        }
        return util;
    }

    /**
     * 保存到sp
     * @param key
     * @param value
     */
    public static void putString(String key, String value) {
        sp.edit().putString(key, value);
    }

    /**
     * 从sp中提取东西
     * @param key
     * @return
     */
    public static String getString(String key) {
        return sp.getString(key, "-1");
    }

}
